<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function multi() {
				var num = document.getElementById("multinum").value;
				var result = 1;
				if (num < 0) {
					result = "负数没有阶乘！";
				}
				if (num == 0) {
					result = 1;
				}
				while (num > 1) {
					result = result * parseInt(num);
					parseInt(num--);
				}
				console.log(result);
				innerResult.innerText = result;
			}
		</script>
	</head>
	<body>
		<input type="text" id="multinum" />
		<input type="button" value="阶乘" onclick="multi()" />
		<span>=</span>
		<span id="innerResult"></span>
	</body>
</html>
